package com.nefu.huiyi.controller;

import com.nefu.huiyi.entity.TitleStatistics;
import com.nefu.huiyi.result.DoctorTitleResult;
import com.nefu.huiyi.service.DoctorTitleService;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import java.util.List;
import java.util.Map;

@RestController
@RequestMapping("/doctor-title")
public class DoctorTitleController {

    private final DoctorTitleService doctorTitleService;

    public DoctorTitleController(DoctorTitleService doctorTitleService) {
        this.doctorTitleService = doctorTitleService;
    }

    /**
     * 获取职称分布数据（映射格式）
     */
    @GetMapping("/distribution")
    public DoctorTitleResult<Map<String, Integer>> getTitleDistribution() {
        Map<String, Integer> distribution = doctorTitleService.getTitleDistribution();
        return DoctorTitleResult.titleDistribution(distribution);
    }

    /**
     * 获取职称统计列表（对象列表格式）
     */
    @GetMapping("/statistics")
    public DoctorTitleResult<List<TitleStatistics>> getTitleStatistics() {
        List<TitleStatistics> statistics = doctorTitleService.getTitleStatistics();
        return DoctorTitleResult.titleStatistics(statistics);
    }
}